
include(CMakeForceCompiler)

set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_VERSION 1)


# where is the target environment
set(CMAKE_FIND_ROOT_PATH $ENV{TOOLCHAIN_LINUX_BOARD_PATH})

set(BINDIR $ENV{TOOLCHAIN_LINUX_BOARD_PATH}/bin CACHE STRING "" FORCE)

set(CMAKE_AR                  ${BINDIR}/$ENV{CROSS_COMPILE}ar)
set(CMAKE_RANLIB              ${BINDIR}/$ENV{CROSS_COMPILE}ranlib)
set(CMAKE_FORCE_C_COMPILER    ${BINDIR}/$ENV{CROSS_COMPILE}gcc)
set(CMAKE_FORCE_CXX_COMPILER  ${BINDIR}/$ENV{CROSS_COMPILE}g++)
set(CMAKE_CXX_FLAGS           "-Wall -std=c++0x" CACHE STRING "" FORCE)

message("   >>> TOOLCHAIN_LINUX_BOARD_PATH = $ENV{TOOLCHAIN_LINUX_BOARD_PATH}")
message("   >>> CROSS_COMPILE              = $ENV{CROSS_COMPILE}")
message("   >>> CMAKE_FORCE_C_COMPILER     = ${CMAKE_FORCE_C_COMPILER}")
message("   >>> CMAKE_FORCE_CXX_COMPILER   = ${CMAKE_FORCE_CXX_COMPILER}")
message("   >>> CMAKE_AR                   = ${CMAKE_AR}")
message("   >>> CMAKE_RANLIB               = ${CMAKE_RANLIB}")
message("   >>> CMAKE_CXX_FLAGS            = ${CMAKE_CXX_FLAGS}")

# search for programs in the build host directories
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)

# for libraries and headers in the target directories
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)

